#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	int a, b, c, d;
	scanf("%d %d", &a, &b);
	if (b > a)
	{
		c = a;
		a = b;
		b = c;
	}
	while(b!=0)
	{
		d = b;
		b = a % b;
		a = d;
	}
	printf("%d\n", a);
	return 0;
}